<?php
header("Content-type:text/html; charset=utf-8;");
require '../../../ppf/fun.php';
require '../../../ppf/pdo_mysql.php';
require '../../../ppf/Filter.php';
date_default_timezone_set("PRC");
$pd=new pdo_mysql();
$filter=new Filter();
session_start();
if(empty($_SESSION['uid'])){
	echo '请登录后再进行操作';exit;
}

$submitMethod=$_SERVER["REQUEST_METHOD"];
if($submitMethod=='POST'){
	$id          =empty($_POST['id'])?0:Filter::filter_number($_POST['id']);
	$type_name  = Filter::safe_string($_POST['name']);
	$remarks       = Filter::safe_string($_POST['remarks']);
	$is_sort         =empty($_POST['odx'])?0:Filter::filter_number($_POST['odx']);
	$repair_user_id = Filter::safe_string($_POST['accept_id']);
	$repair_user_name = Filter::safe_string($_POST['acceptname']);
    //print_r($repair_user_name);exit;
	$in_data=array(
		'name' =>$type_name,
		'remarks'=>$remarks,
		'is_sort'=>$is_sort,
		'repair_user_id'=>$repair_user_id,
		'repair_user_name'=>$repair_user_name
	);
	$result=0;
	$tps='';
	
	if($id==0){
		$result=$pd->insert(array('data'=>$in_data,'table'=>'sys_equipment_repair'));
	}else{
		$result=$pd->update(array('data'=>$in_data,'table'=>'sys_equipment_repair','where'=>"id=".$id));
	}
	
	//print_r($result);exit;
	if(empty($result)){
		$tps='操作失败,请重试';
	}else{
		//return '1';
		$tps='操作成功';
	}

	echo $tps;exit;
}else{
	echo "不允许的表单提交方式，请按正常流程提交表单。";exit;
}
?>